<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="/includes.jsp"%>

<h1 class="layout">Edit State Machine</h1>

<html:errors/>

<html:form action="statemachine.do?method=edit" method="post">
    <html:hidden name="statemachineValueActionForm" property="taskStateMachineId"/>
    <table class="styled" cellspacing="0">
        <tr>
            <th class="styled">Source</th>
            <th class="styled">Destination</th>
            <th class="styled">Status</th>
            <th class="styled">Owner</th>
            <th class="styled">User</th>
            <th class="styled">Roles</th>
            <th class="styled">Delete</th>
        </tr>
        <logic:iterate name="statemachineValueActionForm" property="transitionList" id="transitionList" indexId="index">
            <logic:notEmpty name="transitionList" property="transitionId">
                <html:hidden name="transitionList" indexed="true" property="transitionId"/>
            </logic:notEmpty>
            <tr>
                <td class="styled" style="text-align: center;">
                    <logic:equal name="index" value="0">
                        Start State
                    </logic:equal>
                    <logic:notEqual name="index" value="0">
                        <html:select name="transitionList" indexed="true" property="sourceStateId">
                            <html:options collection="allButStartStatePairs" property="integer" labelProperty="string"/>
                        </html:select>
                    </logic:notEqual>
                </td>
                <td class="styled" style="text-align: center;">
                    <html:select name="transitionList" indexed="true" property="destinationStateId">
                        <html:options collection="statePairs" property="integer" labelProperty="string"/>
                    </html:select>
                </td>
                <td class="styled" style="text-align: center;">
                    <html:select name="transitionList" indexed="true" property="statusId">
                        <html:options collection="statusPairs" property="integer" labelProperty="string"/>
                    </html:select>
                </td>
                <td class="styled" style="text-align: center;">
                    <html:checkbox name="transitionList" indexed="true" property="isOwnerResponsible"/>
                </td>
                <td class="styled" style="text-align: center;">
                    <html:checkbox name="transitionList" indexed="true" property="isUserResponsible"/>
                </td>
                <td class="styled" style="text-align: center;">
                    <html:select multiple="true" size="4" name="transitionList" indexed="true" property="assignedRoleIds" style="width:200">
                        <html:options collection="rolePairs" property="integer" labelProperty="string"/>
                    </html:select>
                </td>
                <td class="styled" style="text-align: center;">
                    <logic:equal name="index" value="0">
                        &nbsp;
                    </logic:equal>
                    <logic:notEqual name="index" value="0">
                        <html:submit indexed="true" property="cmd" value="Delete"/>
                    </logic:notEqual>
                </td>
            </tr>
        </logic:iterate>
    </table>
    <div class="buttons">
        <html:submit property="cmd[0]" value="Add"/>
        <html:submit property="btnSubmit" value="OK"/>
        <html:cancel property="btnSubmit" value="Cancel"/>
    </div>
</html:form>
